#include <bits/stdc++.h>
using namespace std;
int sudu(int ss, int sv, int sa) {
    return sqrt(sv * sv + 2 * sa * ss);
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    int n, m, l, maxv;
    cin >> T;
    for (int t = 0; t < T; t++) {
        cin >> n >> m >> l >> maxv;
        int qi[n], v[n], a[n];
        int car[n];
        for (int i = 0; i < n; i++) {
            cin >> qi[i] >> v[i] >> a[i];
            car[i] = 0;
        }
        int ce[m];
        int cnt[m];
        int yiqi[m][n];
        for (int i = 0; i < m; i++) {
            cin >> ce[i];
            cnt[i] = 0;
        }
        int sum = 0;

        for (int i = 0; i < n; i++) {
            bool flag = false;
            for (int j = 0; j < m; j++) {
                if (ce[j] >= qi[i]) {
                    if (sudu(ce[j] - qi[i], v[i], a[i]) > maxv) {
                        flag = true;
                        yiqi[j][cnt[j]] = i;
                        cnt[j]++;
                        car[i]++;
                    }
                }
            }
            if (flag) {
                sum++;
            }
        }
        int shu = 0;
        cout << sum << " ";
        for (int i = 0; i < m; i++) {
            bool ff = true;
            for (int j = 0; j < cnt[i]; j++) {
                if (car[j] - 1 <= 0) {
                    ff = false;
                }
            }
            if(ff) {
                for (int j = 0; j < cnt[i]; j++) {
                    car[j]--;
                }
                shu++;
            }
        }
        cout << shu;
        shu = 0;
        sum = 0;
    }
    return 0;
}
